#@adminLayout() #define main()
<link href="#(ctx)/static/css/timeline.min.css" rel="stylesheet"/>
<style type="text/css">
    .form-group {
        margin-bottom: 5px;
    }

    .ibox-content {
        padding: 10px;
    }

    .timeline .timeline-item > .timeline-event .timeline-body {
        padding: 0px 5px;
    }

    .timeline .timeline-item > .timeline-event .timeline-footer {
        padding: 0px 5px;
    }

    .timeline .timeline-item > .timeline-event .timeline-heading h4 {
        padding: 0px 5px;
        font-weight: bold;
    }

    .timeline.timeline-single-column.timeline:before {
        left: 12px;
    }

    .timeline.timeline:before {
        left: 12px;
    }

    .timeline.timeline-single-column.timeline .timeline-item > .timeline-point {
        left: 12px !important
    }

    .timeline.timeline-single-column.timeline .timeline-item,
    .timeline.timeline-single-column.timeline .timeline-item.timeline-item-right,
    .timeline.timeline-single-column.timeline .timeline-item:nth-of-type(even):not(.timeline-item-left) {
        padding-left: 40px
    }

    .opinion {
        padding: 0px 10px
    }
</style>

<body class="gray-bg">
<div class="ui-layout-center" id="p_all">
    <div class="container-div" style="padding:0px 20px">
        <div class="row" style="padding:0px;">
            <div class="col-sm-12" id="app2" style="height:100%;padding:0px;">
                <div class="select-list" id="p_btn">
                    <ul>
                        <li>
                            <button type="button" class="btn btn-sm btn-success" onclick="doRefresh()"><i
                                    class="fa fa-arrow-left"></i> 返回
                            </button>

                            #if(status!=2)
                            <button type="button" class="btn btn-sm btn-primary" onclick="doNext()"><i
                                    class="fa fa-check"></i> <span id="span_deal">审批通过</span></button>&nbsp;
                            <button type="button" class="btn btn-sm btn-primary" onclick="doSave()"><i
                                    class="fa fa-floppy-o"></i> 暂存待办
                            </button>&nbsp;
                            #end
                            #if(deal_back!=0&&status!=2&&node_type!='start-node')
                            <button type="button" class="btn btn-sm btn-info" onclick="doBack()" id="btnBack"><i
                                    class="fa fa-backward"></i> <span id="sp_back">发回</span>
                            </button>&nbsp;
                            #end

                            #if(is_cancel==1)
                            <button type="button" class="btn btn-sm btn-warning" onclick="doCancel()"><i
                                    class="fa fa-floppy-o"></i> 作废
                            </button>&nbsp;
                            #end
                            <!--<button type="button" class="btn btn-sm btn-success" onclick="doDraw()" id="btnDraw"><i class="fa fa-picture-o"></i> 流程图</button>&nbsp;-->

                            <button type="button" class="btn btn-sm btn-info" onclick="doHistroy()" id="btnHis"><i
                                    class="fa fa-history"></i> 审批详情
                            </button>&nbsp;
                        </li>
                        <li style="line-height:30px;font-weight:bold;">
                            #(wf_desc)
                        </li>
                    </ul>
                </div>
                #if(status!=2)
                <div class="wrapper animated fadeInRight ibox-content" id="p_msg">
                    <form id="form-config-add" method="post" class="form-horizontal">
                        <div class="form-group">
                            <div style="display: none">
                                <div class="col-sm-1" style="text-align:right">

                                </div>
                                <div class="col-sm-11">
                                    <label class="opinion">
                                        <input type="radio" checked name="opinion1" value="已阅">已阅</label>
                                    <label class="opinion">
                                        <input type="radio" name="opinion1" value="同意">同意</label>
                                    <label class="opinion">
                                        <input type="radio" name="opinion1" value="不同意">不同意</label>
                                </div>
                            </div>

                            <div class="col-sm-1" style="text-align:right">
                                意见
                            </div>
                            <div class="col-sm-9">
                                <textarea rows="2" class="form-control" name="description"
                                          id="description">同意</textarea>
                            </div>

                            <div class="col-sm-2">
                                <a class="btn btn-primary btn-rounded btn-sm"
                                   onclick="openFile()"><i class="fa fa-paperclip" aria-hidden="true"></i> <span
                                        id="sub_file">附件</span></a>
                            </div>
                        </div>
                    </form>
                </div>
                #end

                <div class="wrapper animated fadeInRight ibox-content" id="p_content" style="height:100%;padding:0px;">
                    <iframe id="iframe1" name="iframe1" width="100%" height="100%" style="border:none"
                            src="#(ctx)/jwflow_task"></iframe>
                </div>
            </div>

        </div>
    </div>
</div>
<div class="ui-layout-east" style="padding:5px;">
        <div class="timeline timeline-single-column">
            #for(item:hislist)
            <!--<span class="timeline-label">
            <span class="label label-primary">#(item.create_time)</span>
            </span>-->
            <div class="timeline-item">
                #if(item.description.indexOf('发回')==-1||item.description==null)
                <div class="timeline-point timeline-point-success">
                    <i class="fa fa-star" style></i>
                </div>
                #else
                <div class="timeline-point timeline-point-warning">
                    <i class="fa fa-star" style></i>
                </div>
                #end
                <div class="timeline-event">
                    <div class="timeline-heading">
                        <h4>#(item.node_id)</h4>
                    </div>
                    <div class="timeline-body">
                        <p>#(item.description)</p>
                    </div>
                    <div class="timeline-footer">
                        <p class="text-right">#(item.create_by)</p>
                        <p class="text-right">#(item.create_time)</p>
                    </div>
                </div>
            </div>
            #end
        </div>
</div>

<script type="text/javascript">
    var prefix = "#(ctx)/jwflow_deal";
    var wf_id = '#(wf_id)';
    var task_id = '#(task_id)';
    var node_id = '#(node_id)';		//需要处理的下一个节点
    var node_type = '#(node_type)';
    var detail_url = '#(detail_url)';

    var deal_back = '#(deal_back)';			//是否发回
    var deal_attr = '#(deal_attr)';			//自动/人工
    var deal_type = '#(deal_type)';			//单人/会签处理

    $(function () {
        //设置内容高度
        $('#p_content').height($('body').height() - $('#p_btn').height() - $('#p_msg').height() - 65);

        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, east__size: 260});

        if(deal_back=='1')
        {
            $("#sp_back").text("发回开始");
        }
        else if(deal_back=='2')
        {
            $("#sp_back").text("发回上节点");
        }
        else if(deal_back=='3')
        {
            $("#sp_back").text("发回任意");
        }

        if (detail_url.indexOf("?") > 0) {
            $('#iframe1').attr("src", detail_url + "&id=" + task_id + "&iswf=true");
        } else {
            $('#iframe1').attr("src", detail_url + "?id=" + task_id + "&iswf=true");
        }
    });

    //审批可能弹框
    function doNext() {
        doNextOK("");
    }

    //审批处理
    function doNextOK(node_id) {
        $.modal.confirm("确认要处理前流程吗？",function() {
            if ($.validate.form()) {
                var options = {
                    dataType: "json",
                    url: prefix + "/dealNext",
                    data: {task_id: task_id, node_id: node_id, wf_id: wf_id, sel_user: ''},
                    success: function (data) {
                        if (data.code == 0) {
                            taskCommited();
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                };
                $("#form-config-add").ajaxSubmit(options);
            } else {
                $(window).scrollTop(0);
                layer.msg('您有必填项未输入！');
            }
        });
    }

    //暂存
    function doSave() {

    }

    //发回
    function doBack() {
        //询问框
        $.modal.confirm("确认要发回当前流程吗？",function() {
            if ($.validate.form()) {
                var options = {
                    dataType: "json",
                    url: prefix + "/dealBack",
                    data: {task_id: task_id, node_id: node_id, wf_id: wf_id, sel_user: ''},
                    success: function (data) {
                        if (data.code == 0) {
                            taskCommited();
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                };
                $("#form-config-add").ajaxSubmit(options);
            } else {
                $(window).scrollTop(0);
                layer.msg('您有必填项未输入！');
            }
        });
    }

    //取消
    function doCancel() {
        //询问框
        $.modal.confirm("确认要作废当前流程吗？",function() {
            if ($.validate.form()) {
                var options = {
                    dataType: "json",
                    url: prefix + "/dealCancel",
                    data: {task_id: task_id, node_id: node_id, wf_id: wf_id, sel_user: ''},
                    success: function (data) {
                        if (data.code == 0) {
                            taskCommited();
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                };
                $("#form-config-add").ajaxSubmit(options);
            } else {
                $(window).scrollTop(0);
                layer.msg('您有必填项未输入！');
            }
        });
    }

    function doDraw() {
        var url = "#(ctx)/jwflow_view?task_id=" + task_id + "&wf_id=" + wf_id + "&node_id=" + node_id;

        showWinFull('流程查看', url); //注意第二个参数
    }

    function doHistroy() {
        var url = "#(ctx)/jwflow_view/history?task_id=" + task_id + "&wf_id=" + wf_id + "&node_id=" + node_id;

        showWinFull('审批详情', url); //注意第二个参数
    }

    //提交成功之后跳转页面
    function taskCommited() {
        window.location = "#(ctx)/jwflow_task?range=deal";
    }

    //返回上一页面
    function doRefresh() {
        taskCommited();		//返回一页
    }

</script>
</body>
#end
